package com.ibeetl.cms.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.cms.dao.GreenTreatmentDao;
import com.ibeetl.cms.entity.GreenTreatment;
import com.ibeetl.cms.web.query.GreenTreatmentQuery;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * GreenTreatment Service
 */

@Service
@Transactional
public class GreenTreatmentService extends BaseService<GreenTreatment>{

    @Autowired private GreenTreatmentDao greenTreatmentDao;

    public PageQuery<GreenTreatment>queryByCondition(PageQuery query){
        PageQuery ret =  greenTreatmentDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelGreenTreatment(List<Long> ids){
        try {
            greenTreatmentDao.batchDelGreenTreatmentByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除GreenTreatment失败", e);
        }
    }

    public PageQuery<GreenTreatment> queryEmployees(PageQuery page) {
        page.setPageSize(Integer.MAX_VALUE);

        PageQuery ret =  greenTreatmentDao.queryEmployees(page);
        queryListAfter(ret.getList());
        return ret;
    }

    //查企业
    public PageQuery<GreenTreatment>findenterprise(PageQuery query){
        PageQuery ret =  greenTreatmentDao.findenterprise(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public List<GreenTreatment>queryCompany(GreenTreatmentQuery condtion){
        List<GreenTreatment> ret =  greenTreatmentDao.queryCompany(condtion);
        queryListAfter(ret);
        return ret;
    }
    public PageQuery<GreenTreatment> queryDoneTask(PageQuery page) {
        PageQuery ret =  greenTreatmentDao.queryDoneTask(page);
        queryListAfter(ret.getList());
        return ret;

    }

    public int queryEmployeesCount(GreenTreatmentQuery condition) {
        return greenTreatmentDao.queryEmployeesCount(condition);
    }
}